<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../vue.2.5.1.js"></script>
</head>

<body>
    <div id='app'>
        <input type="text" v-focus>
        <div v-test:msg.a.b='message'></div>
    </div>
    <script>
        // //全局注册
        // Vue.directive('focus',{
        //     //指令选项
        // });
        // //局部注册
        // var app = new Vue({
        //     el:'#app',
        //     directives:{
        //         focus:{
        //             //指令选项
        //         }
        //     }
        // });
        Vue.directive('focus', {
            inserted: function(el) {
                //聚焦元素
                el.focus();
            }
        });
        Vue.directive('test', {
            bind: function(el, binding, vnode) {
                var keys = [];
                for (var i in vnode) {
                    keys.push(i);
                }
                el.innerHTML =
                    'name:' + binding.name + '<br>' +
                    'value:' + binding.value + '<br>' +
                    'expression:' + binding.expression + '<br>' +
                    'argument:' + binding.arg + '<br>' +
                    'modifiers:' + JSON.stringify(binding.modifiers) + '<br>' +
                    'vnode keys' + keys.join(',')
            }
        })
        var app = new Vue({
            el: '#app',
            data: {
                message: 'some text'
            }
        })
    </script>
</body>

</html>